package com.fz.controller.merchant;

import com.fz.aop.login.AnonymousAccess;
import com.fz.common.ResponseEntity;
import com.fz.dto.merchant.merMenu.MerMenuAdd;
import com.fz.dto.merchant.merMenu.MerMenuQuery;
import com.fz.dto.merchant.merMenu.MerMenuUpd;
import com.fz.service.merchant.MerMenuService;
import com.fz.vo.merchant.merMenu.MerMenuTreeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiSort;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "菜单管理")
@RequestMapping("/merMenu")
@SuppressWarnings("unchecked")
@ApiSort(value = 4)
public class MerMenuController {

    @Resource
    private MerMenuService merMenuService;

    @GetMapping("/findMerMenu")
    @ApiOperation(value = "菜单树")
    @ApiOperationSupport(order = 1)
    @AnonymousAccess
    public ResponseEntity<MerMenuTreeVo> findMerMenu(MerMenuQuery merMenuQuery) throws Exception{
        return merMenuService.findMerMenu(merMenuQuery);
    }


    @PostMapping("/addMerMenu")
    @ApiOperation(value = "新增菜单")
    @ApiOperationSupport(order = 3)
    @AnonymousAccess
    public ResponseEntity addMerMenu(@RequestBody MerMenuAdd merMenuAdd) throws Exception{
        merMenuService.addMerMenu(merMenuAdd);
        return ResponseEntity.buildSuccess();
    }

    @PostMapping("/updateMerMenu")
    @ApiOperation(value = "修改菜单")
    @ApiOperationSupport(order = 4)
    @AnonymousAccess
    public ResponseEntity updateMerMenu(@RequestBody MerMenuUpd merMenuUpd) throws Exception{
        merMenuService.updateMerMenu(merMenuUpd);
        return ResponseEntity.buildSuccess();
    }

}
